//用户管理路由
const express = require('express')
const routerUsers = express.Router()
    //导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
    //导入需要验证的规则对象
const reg_schema = require('../schema/schema')
    //引入用户列表的处理函数
const handle = require('../router_handler/Users')
routerUsers.get('/users', handle.getUsers)
    // 添加
routerUsers.post('/users', expressJoi(reg_schema.user_create_schema), handle.addUsers)
    // 编辑
routerUsers.put('/users/:id', expressJoi(reg_schema.user_update_schema), handle.editUsers)
    // 查询
routerUsers.get('/users/:id', handle.searchUsers)
    // 改变状态
routerUsers.put('/users/:uId/state/:type', handle.changeState)
    // 删除图书
routerUsers.delete('/users/:id', handle.deleteUsers)
    // 分配
routerUsers.put('/users/:id/role', handle.distributeUsers)
module.exports = routerUsers